package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.MyIndentBean;
import com.lwj.liwanjia.impl.MyIndentView;
import com.lwj.liwanjia.model.MyIndentModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/18.
 */

public class MyIndentPresenter {
    private MyIndentView myIndentView;
    private MyIndentModel myIndentModel;

    public MyIndentPresenter(MyIndentView myIndentView) {
        this.myIndentView = myIndentView;
        myIndentModel = new MyIndentModel();
    }

    public void getIndentData(String token, String status) {
        if (myIndentView != null) {
            myIndentModel.getIndentData(token, status, new Subscriber<MyIndentBean>() {
                @Override
                public void onCompleted() {
                    myIndentView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                    myIndentView.showError((Exception) e);
                    myIndentView.hideProgress();
                }

                @Override
                public void onNext(MyIndentBean myIndentBean) {
                    myIndentView.getIndentData(myIndentBean);
                }

                @Override
                public void onStart() {
                    super.onStart();
                    myIndentView.showProgress();
                }
            });
        }
    }
}
